package com.ruoyi.expo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.expo.domain.ExCarousel;
import com.ruoyi.expo.service.IExCarouselService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 展会轮播Controller
 * 
 * @author code_yong
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/expo/carousel")
public class ExCarouselController extends BaseController
{
    @Autowired
    private IExCarouselService exCarouselService;

    /**
     * 查询展会轮播列表
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExCarousel exCarousel)
    {
        startPage();
        List<ExCarousel> list = exCarouselService.selectExCarouselList(exCarousel);
        return getDataTable(list);
    }

    /**
     * 导出展会轮播列表
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:export')")
    @Log(title = "展会轮播", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExCarousel exCarousel)
    {
        List<ExCarousel> list = exCarouselService.selectExCarouselList(exCarousel);
        ExcelUtil<ExCarousel> util = new ExcelUtil<ExCarousel>(ExCarousel.class);
        util.exportExcel(response, list, "展会轮播数据");
    }

    /**
     * 获取展会轮播详细信息
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(exCarouselService.selectExCarouselById(id));
    }

    /**
     * 新增展会轮播
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:add')")
    @Log(title = "展会轮播", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExCarousel exCarousel)
    {
        return toAjax(exCarouselService.insertExCarousel(exCarousel));
    }

    /**
     * 修改展会轮播
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:edit')")
    @Log(title = "展会轮播", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExCarousel exCarousel)
    {
        return toAjax(exCarouselService.updateExCarousel(exCarousel));
    }

    /**
     * 删除展会轮播
     */
    @PreAuthorize("@ss.hasPermi('expo:carousel:remove')")
    @Log(title = "展会轮播", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(exCarouselService.deleteExCarouselByIds(ids));
    }
}
